package cn.liziguo.tank.collision;

import cn.liziguo.tank.config.GameConfig;
import cn.liziguo.tank.constants.GameEnum;
import cn.liziguo.tank.script.BulletComponent;
import com.almasb.fxgl.entity.Entity;
import com.almasb.fxgl.physics.CollisionHandler;

/**
 * @author Liziguo
 * @date 2022-07-09 21:26:11
 */
public class BulletGreensCollisionHandler extends CollisionHandler {

    public BulletGreensCollisionHandler() {
        super(GameEnum.BULLET, GameEnum.GREENS);
    }

    @Override
    protected void onCollisionBegin(Entity bullet, Entity map) {
        if (bullet.getComponent(BulletComponent.class).level >= GameConfig.DESTROY_GREENS_BULLET_LEVEL) {
            map.removeFromWorld();
        }
    }
}
